// 1. 给对象添加类型
type Person = {
    name: string
    age: number
    isMarry: boolean
}

const p1: Person = {
    name: '张三',
    age: 18,
    isMarry: false
}

const p2: Person = {
    name: '李四',
    age: 28,
    isMarry: true,
}

// 2.  type + 交叉类型模拟继承
type CarBase = {
    width: number
    height: number
    weight: number
}

type Su7 = CarBase & {
    name: string
}

type Auto = CarBase & {
    brand: string
}

const su7: Su7 = {
    name: '小米su7',
    width: 3,
    height: 3,
    weight: 3
}

// 3. 思考题
type Res = {
    code: number
    msg: string
    data: {
        title: string
        content: string
    }
}

const res: Res = {
    code: 200,
    msg: 'success',
    data: {
        title: '超厉害',
        content: '88888'
    }
}

// 4. type和interface的区别
// 非常适合底层封装
interface Dog {
    name: string
}

interface Dog {
    age: number
}

const dog: Dog = {
    name: '小花',
    age: 18,
}

// type Cat = {
//   name: string
// }

// type Cat = {
//   age: number
// }

export { p1, p2, su7, res, dog }